<title>旺进财</title>
#@homejs()
<script src="#(path)/assets/js/zdialog.js"></script>
<link rel="stylesheet" href="#(path)/assets/css/zdialog.css">
<script src="#(path)/assets/js/jquery.pagination.js"></script>
<link rel="stylesheet" href="#(path)/assets/css/pagination.css">
<body  bgcolor="#fafafa" style="margin:0px; position:relative"> 
<div class="sd_logo"></div>
<div class="sd_img10"></div>
<div class="sd_img11"></div>
<div class="sd_img12"></div>
<div class="sd_img13"></div>
	#@homemenu("trade")
	<div align="center" style="width:100%"> 
		<div style="width:1190px;">
			<!--选择区域-->
			<div align="left" style="line-height:70px;width:100%;margin-top:10px;height:210px;background:#FFF; margin-top:40px; margin-bottom:40px;position:relative;z-index:11;border-radius:10px;">
				<div style="height:70px;width:100%;border-bottom:1px solid #ebebeb"> 
					<span style="margin:0 20px 0 20px;">标的类别</span>
					<span seleinfo1="" class="leibie yuefen yuefens">全部</span>
					<span seleinfo1="first" class="leibie yuefen">新手标</span>
					<span seleinfo1="experi" class="leibie yuefen">体验标</span>
					<span seleinfo1="public" class="leibie yuefen">常规标</span> 
				</div>
				<div style="height:70px;width:100%;border-bottom:1px solid #ebebeb">
					<span style="margin:0 20px 0 20px;">投资期限</span>
					<span seleinfo1="" class="qixian yuefen yuefens">全部</span>
					<span seleinfo1="30" class="qixian yuefen">1个月</span>
					<span seleinfo1="60" class="qixian yuefen">2个月</span>
					<span seleinfo1="90" class="qixian yuefen">3个月</span> 
					<span seleinfo1="180" class="qixian yuefen">6个月</span>
					<span seleinfo1="360" class="qixian yuefen">12个月</span>
				</div>
				<div style="height:70px;width:100%;">
					<span style="margin:0 20px 0 20px;">预期年化</span>
					<span seleinfo2=""  class="nianhua yuefen yuefens">全部</span>
					<span seleinfo2="5"  class="nianhua yuefen">5%以上</span> 
					<span seleinfo2="10" class="nianhua yuefen">10%以上</span>
					<span seleinfo2="15" class="nianhua yuefen">15%以上</span>
					<span seleinfo2="20"  class="nianhua yuefen">20%以上</span>
				
				</div>
			</div> 
			<!--标的列表--> 
			<div id="tradeall" style="width:1190px;margin-top:10px;background:#FFF;min-height:500px; position:relative; z-index:11">
			</div>
			
			<!--分页-->
			<div align="center" style="font-size:14px;height:50px;width:100%;padding:10px 0;background:#FFF;line-height:50px;">
				<div align="center" class="M-box2"></div>
			</div>
		</div>
	</div>
	<!--@paginate(page.pageNumber, page.totalPage, "/blog/")-->

<script id="demo" type="text/x-jquery-tmpl">
	<div align="left" style="width:1110px;height:150px;padding:10px 40px 20px 40px;border-bottom:1px solid #ebebeb">
		<div style="border-bottom:1px solid #ebebeb;width:1110px;font-size:18px;font-weight:400;line-height:50px;">
			<span>${name}</span>
			<span ${firsthid}  class="jxyc">仅限一次</span>  	
			<span ${experihid}  class="tyjky">体验金可用</span> 
			<img ${dxhid} style="margin:10px 0 0 10px;" src="#(path)/assets/home/trade/tradeclose.png">
		</div>
		<div style="width:1110px;padding-top:15px;">
			<div align="left" style="width:200px;float:left">
				<div style="color:#ee3b3f;font-size:34px;"><span>${rate}%</span><span style="color:#ff6f4d;font-size:20px">${plus_rate}</span></div>
				<div style="margin-top:12px;color:#a9a8a6">预期年化</div>
			</div>
			<div align="left" style="width:160px;float:left">
				<div style="color:#393939;font-size:36px;"> 
					<span>${day_limit}						
						<span style="color:#a8a7a5;font-size:18px;margin-left:-5px;">天</span>
					</span>
				</div>
				<div style="margin-top:12px;color:#a9a8a6">预期期限</div>
			</div>
			<div align="left" style="width:204px;float:left;margin-top:15px;">
				<div style="color:#626262;font-size:16px;">起投份数${least_unit}份</div>
				<div style="margin-top:20px;color:#626262">融资金额：${amount}元</div>
			</div>
			<div align="left" style="width:300px;float:left;margin-top:15px;">
				<div style="color:#626262;font-size:16px;">
					<div >
						<div style="height:20px;line-height:20px;float:left;font-size:16px;color:#616161">投资进度：</div>
						<div style="float:left;width:80px;height:32px;overflow:hidden;">
							<div style="overflow:hidden;border-radius:5px;position:relative;float:left;margin-top:5px;height:10px;width:100%;background:#fa3048">
								<div id="jindu${id}" style="position:relative;float:left;height:10px;width:100%;background:#eee"></div>
							</div>   
						</div>
						<div style="height:20px;line-height:20px;float:left;margin-left:10px;font-size:16px;color:#616161">${jindu}%</div>
					</div>
				</div>
				<div style="margin-top:40px;clear:both;color:#626262">剩余可投：${shengyu}</div> 
			</div>
			<div align="left" style="width:224px;float:left;margin-top:20px;">
				<div status="${status}" bidname2="${name}" bidid="${id}" TimeStamp="${startTimeStamp}" class="${tradeclass} status" align="center" >
					${tradeinfo}
				</div> 
			</div>
		</div>
	</div>
</script>

<script>
	var page = 1;
	var day = "";
	var rate = "";
	var size = 10; 
	var pageNumber ="1";
	var totalPage;
	var totalRow;
	var types="";
	getalllist(size,page,day,rate,types)
	$(".qixian").click(function(){
		$(".qixian").removeClass("yuefens"); 
		$(this).addClass("yuefens");
		day = $(this).attr("seleinfo1");
		$("#tradeall").empty();
		getalllist(size,page,day,rate,types)
	});
	$(".leibie").click(function(){
		$(".leibie").removeClass("yuefens"); 
		$(this).addClass("yuefens");
		types = $(this).attr("seleinfo1");
		$("#tradeall").empty();
		getalllist(size,page,day,rate,types)
	});
	$(".nianhua").click(function(){
		$(".nianhua").removeClass("yuefens"); 
		$(this).addClass("yuefens"); 
		rate = $(this).attr("seleinfo2");
		$("#tradeall").empty();
		getalllist(size,page,day,rate,types)
	}); 
	function printpage(index){
		page = index;
		$("#tradeall").empty();
		getalllist(size,page,day,rate,types)
	}
	function getalllist(size,page,day,rate,types){
		var url = "#(path)/bids?type="+types+"&size="+size+"&status=full*trading*finish*waiting*repaying&page="+page+"&day="+day+"&rate="+rate;
		$.getJSON(url, function(tradeall) {
			console.log(tradeall);
			var k = 0;
			if(tradeall.data.page.list.length==0){
				$("#tradeall").append("<div align='center' style='height:50px;line-height:50px;'>旺~抱歉，暂无数据！</div>");
			} else{
				totalPage = tradeall.data.page.totalPage; 
				totalRow = tradeall.data.page.totalRow; 
				pageNumber = tradeall.data.page.pageNumber;
				$('.M-box2').pagination({
					coping:true,
					current:pageNumber,
					totalData:totalRow, //数据总条数
					showData: 10, //每页显示的条数
					pageCount: totalPage, //总页数,默认为9
					homePage:'首页',
					endPage:'末页',
					prevContent:'上一页',
					nextContent:'下一页',
				});
				$.each(tradeall.data.page.list, function(i, item){ 
					var experihid = "hidden";
					var firsthid = "hidden"; 
					var dxhid = "hidden"; 
					var jindu = (Number(item.avunit) * Number(item.unit_amount)*100/ Number(item.amount)).toFixed(2);
					if(item.type == "experi"){
						var shengyu = (Number(item.unit)-Number(item.avunit)).toFixed(2)+" 元";
						experihid = "show";
					}else { 
						var shengyu = Number(item.unit)-Number(item.avunit)+" 份";
						if(item.type == "first"){ 
							firsthid = "show"
						}
					}
					if(item.is_direct=="1"){ 
						dxhid = "show";
					}
					if(item.status=="trading"){
						var tradeclass = "tradebutton1";
						var tradeinfo = "立即投资"; 
					}else if(item.status=="waiting"){
						var tradeclass = "tradebutton2"; 
						//var tradeinfo = "未开始"; 
						k = k+1; 
					}else if(item.status=="full"){
						var tradeclass = "tradebutton1";
						var tradeinfo = "已满标"; 
					}else if(item.status=="repaying"){
						var tradeclass = "tradebutton3";
						var tradeinfo = "还款中"; 
					}else if(item.status=="finish"){
						var tradeclass = "tradebutton4";
						var tradeinfo = "已还款"; 
					}  
					if(item.plus_rate=="0.0"){
						var plus_rate="";
					}else{
						var plus_rate="+"+item.plus_rate+"%";
					}
					var invests = {startTimeStamp:item.startTimeStamp,plus_rate:plus_rate,status:item.status,tradeinfo:tradeinfo,tradeclass:tradeclass,dxhid:dxhid,experihid:experihid,firsthid:firsthid,shengyu:shengyu,id:item.id,jindu:jindu,amount:item.amount,name:item.name,rate:item.rate,day_limit:item.day_limit,least_unit:item.least_unit,amount:item.amount}; 
					$("#demo").tmpl(invests).appendTo('#tradeall');
					$("#jindu"+item.id).animate({left:jindu+'%'},1000);
					$(".cont6,.cont6>div").css("height",(181*tradeall.data.page.list.length+60)+"px").show();
				});
				setInterval(function countTime() {
					for(j=0;j<k;j++){
						var that = $(".status").eq(j);
						var startTimeStamp = that.attr("TimeStamp"); 
						startTimeStamp=startTimeStamp-1000;
						that.attr("TimeStamp",startTimeStamp);
						startTimeStamp = (startTimeStamp/1000).toFixed(0);
						/*var day1=Math.floor(startTimeStamp/(60*60*24)); 
						var hour=Math.floor((startTimeStamp-day1*24*60*60)/3600); 
						var minute=Math.floor((startTimeStamp-day1*24*60*60-hour*3600)/60); 
						var second=Math.floor(startTimeStamp-day1*24*60*60-hour*3600-minute*60); */
						var hour=Math.floor((startTimeStamp/3600)); 
						var minute=Math.floor((startTimeStamp-hour*3600)/60); 
						var second=Math.floor(startTimeStamp-hour*3600-minute*60);
						console.log();
						that.html("倒计时："+hour+":"+minute+":"+second); 
						if(startTimeStamp <=0){
							window.location.reload();
						}
					}
				},1000);
				$(".status").click(function(){
					var status = $(this).attr("status");
					var bidname2 = $(this).attr("bidname2");
					var bidid = $(this).attr("bidid"); 
					if("#(session.token??)"==""){
						$.DialogByZ.Alert({Title: "提示", Content: "这位客官，您还未登录，请先登录！",BtnL:"确定",FunL:alerts});
					}else{
						ajax("#(path)/user/checkToken?token=#(session.token??)",{},function(data){
							if(data.msg=='TOKEN校验失败！'){
								$.DialogByZ.Alert({Title: "提示", Content: "您的账号在其他设备登录！如有疑问请拨打客服热线400-800-8117！",BtnL:"确定",FunL:alerts});
							}else if(data.msg=='TOKEN超时！'){
								$.DialogByZ.Alert({Title: "提示", Content: "登陆超时，请重新登陆！",BtnL:"确定",FunL:alerts});
							}else{
								console.log(bidid);
								if(status=="finish"){
									$.DialogByZ.Alert({Content:bidname2+" 已正常还款，为保障借款人信息安全，故不予显示相关信息，还请谅解"});
								}else{
									window.location.href='#(path)/trade-tradeinfo?id='+bidid;
								}
							} 
						});
					} 
				});
			}
		});
	}

function confirmL(){
	$.DialogByZ.Close();
}
function alerts(){
	$.DialogByZ.Close();
	location.href="#(path)/user-login";
}
function Immediate(){
	location.href="#(path)/user-login";
}
</script>
	#@homefoot1()
	#@homefoot2()